"""
.. module:: Price
   :platform: Unix, Windows
   :synopsis: This is the base class for the price heirarchy

.. moduleauthor:: Nick Leaton <nickle@gmail.com>

"""
from Entities.Entity import Entity

class Price (Entity):
    '''
    Base class for all prices
    '''
    
    def __init__ (self, bid, ask, close, when):
        '''
        Args:
            bid:   bid price
            ask:   ask price
            close: close or settlement price
            when:  time/date of price
        '''
        Entity.__init__ (self)
        self.bid   = bid
        self.ask   = ask
        self.close = close
        self.when  = when
        
    def spread (self):
        '''
        Get the spread
        '''
        return self.ask - self.bid
    
    def mid (self):
        '''
        Get the mid price
        '''
        return (self.ask + self.bid) / 2.0
    
    
